<?php
/*
 * This file is part of Compost.
 *
 * Compost is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Compost is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Compost.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Default Controller overridden to start the session
 */
class MY_Controller extends Controller{
	var $data = array();
	function MY_Controller(){
		parent::Controller();
		session_start();
	}
}

/**
 * Use this class to make sure that the user is authenticated prior to letting them see a page
 */
class Authenticated_Controller extends MY_Controller{
	function Authenticated_Controller(){
		parent::MY_Controller();
		check_login();
	}
}

/**
 * Use this class to make sure that the user is an admin prior to letting them see a page
 */
class Admin_Controller extends Authenticated_Controller{
	function Admin_Controller(){
		parent::Authenticated_Controller();
		if ($_SESSION['userrole'] != '-1') {
			redirect(base_url() . index_page() . 'client/open/' . $_SESSION['userrole']);
		}
	}
}